<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <!--<link rel="stylesheet" type="text/css" href="../css/css.css"/>-->
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_1141457_4od1qwryv03.css">
    <style type="text/css">
        header {
            width: 100%;
            z-index: 100000;
            color: #000000;
            border-bottom: 1px solid #DCDCDC;
            background: url("../image/headerbg.png") no-repeat;
            background-size: 100% 100%;
            height: 70px;
            display: flex;
            justify-content: center;
            align-items: center;

        }
        header span{
            color: #fff;
            font-size: 18px;
            padding-top: 20px;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="aui-content aui-margin-b-15">
        <header>
            <span>约会</span>
        </header>
    </div>
</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script src="../script/vue2.js"></script>
<script type="text/javascript">
    apiready = function () {
        // 打开聊天
        function openchat() {
            if (!$api.getStorage('chat')) {
                $api.setStorage('chat', 1)
                api.openFrame({
                    name: 'chat',
                    url: './chat.html',
                    rect: {
                        x: 0,
                        y: 70,
                        w: 'auto',
                        h: api.winHeight - 120
                    }
                });
            } else {
                api.setFrameAttr({
                    name: 'chat',
                    hidden: false
                });
            }
        }

        var vm = new Vue({
            el: "#app",
            data: {
                title: '忘记密码',
                newpassword: '',
                mobile: '',
                captcha: '',
                getcode_title: '获取验证码',
                countdown: 0,
                nickname: '',
                avatar: '',
                release: false,
                bannerList: [],
                recommandList: [],
                categoryList: [],
                index: 0,
                isyuehui: false
            },
            mounted: function () {
                var that = this;
                // $api.rmStorage('userInfo')
                if (!$api.getStorage('userInfo')) { //判断是否登录
                    if (api.systemType == "ios") {
                        var times = 0;
                    } else {
                        var times = 300;
                    }
                    api.openWin({ //未登录打开登陆窗口
                        name: 'login',
                        url: './html/login/login.html',
                        delay: times,
                        slidBackType: 'edge',
                        vScrollBarEnabled: false,
                        slidBackEnabled: false,
                    })
                } else {
                    // var mobile = $api.getStorage('userInfo').mobile
                    // ajpushs(mobile)
                }
                api.addEventListener({
                    name: 'isLogin'
                }, function (ret, err) {
                    that.openframes()
                });
                $api.rmStorage('chat')
                that.getrefUserinfo()
            },
            methods: {
                // 打开聊天界面
                openframes: function () {
                    openchat()
                },
                getrefUserinfo: function () {
                    var that = this;
                    var token = $api.getStorage('userInfo').token
                    console.log(token);
                    api.ajax({
                        url: ajaxRoute.center,
                        method: 'post',
                        data: {
                            values: {
                                token: token
                            }
                        }
                    }, function (res, err) {
                        if (res.code == 1) {
                            if (res.data.stage == 1) {
                                that.openframes()
                            } else {
                                api.setFrameAttr({
                                    name: 'chat',
                                    hidden: true
                                });
                                api.openFrame({
                                    name: 'regs',
                                    url: 'widget://html/reg/perfect.html',
                                    rect: {
                                        x: 0,
                                        y: 0,
                                        w: 'auto',
                                        h: 'auto'
                                    },
                                    pageParam: {
                                        id: res.data.stage
                                    }
                                });
                            }
                        } else {
                            api.hideProgress();
                            api.toast({msg: res.msg, location: 'middle'});
                        }
                    });
                },
            },
            filters: {
                filtersImg: function (img) {
                    var imgs = ajaxUrl + '/' + img
                    return imgs;
                },
                filtersNav: function (e) {
                    var s = parseInt(e) + 1;
                    var img = 'image/nav-' + s + '.png'
                    return img;
                }
            }
        })

    }
</script>
</html>
